#ifndef MAINSCENE_H
#define MAINSCENE_H

#include <QWidget>
#include <QPixmap>
#include <QTimer>
#include <QKeyEvent>
#include <QList>
#include "config.h"
#include "Explosion.h"
#include "Bullet.h"

class Enemy
{
public:
    QPixmap enemy;
    int x;
    int y;
    bool isFree;
    int speed;
    int type;
    int health;
    Explosion* explosion;

    Enemy(int type = 1);
    ~Enemy();
    void updatePosition();
    void down();
};

class Hero
{
public:
    QPixmap hero;
    int x;
    int y;
    int speed;
    QRect rect;
    Explosion* explosion;

    Hero();
    ~Hero();
    void updatePosition();
    void down();
};

class MainScene : public QWidget
{
    Q_OBJECT

public:
    MainScene(QWidget *parent = nullptr);
    ~MainScene();

    void initScene();
    void playGame();
    void updatePosition();
    void paintEvent(QPaintEvent *event);
    void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);
    void collisionDetection();
    void enemyToScene();


    void addBullet(int index, Bullet bullet);

private:
    QPixmap m_map;
    int m_map1_posY;
    int m_map2_posY;
    QTimer m_Timer;

    Hero m_hero;
    Bullet m_bullets[30];
    Bullet m_enemyBullets[30];
    Enemy m_enemys[20];

    bool m_keyUp;
    bool m_keyDown;
    bool m_keyLeft;
    bool m_keyRight;

    int m_recorder;
    int m_bulletRecorder;
};

#endif // MAINSCENE_H
